package com.wr.sqlSession;

import com.wr.config.XmlConfigBuilder;
import com.wr.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * @author 王瑞
 * @Description :
 * @date 2020/1/29 - 19:01
 */
public class SqlSessionFactoryBuilder {

    /*
    *根据配置文件的字节输入流 来构建一个SqlSessionFactory工程类
    * 这里要做的主要工作就是解析这个字节输入流中的配置文件信息 并把解析的内容封装到configuration对象中
    * */
    public SqlSessionFactory build(InputStream in) throws DocumentException, PropertyVetoException {
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder();
        //解析
        Configuration configuration = xmlConfigBuilder.parseConfig(in);
        SqlSessionFactory sqlSessionFactory = new DeafaultSqlSessionFactory(configuration);

        return sqlSessionFactory;
    }

}
